<template>
    <MyTable :theadList='tableThead' :renderData='moviesData'>
        <template #operate="{item}">
            <td><button @click="deleteMovie(item._id)">删除</button><button>修改</button></td>
        </template>
        <template #hot="{item}" >
            <td>{{ item.hot?'是':'否' }}</td>
        </template>
        <template #types="{item}">
            <td>{{ item.types.join('/') }}</td>
        </template>
    </MyTable>
    <!-- <MyTable :theadList='shopHeader' :renderData='shopArray'/> -->
</template>

<script setup>
import { ref } from 'vue';
import MyTable from '../globalComponents/MyTable.vue';

const moviesData = ref([
    {
        "_id": "682d9da7573f2ec0eb01fb5b",
        "name": "攻壳机动队",
        "duration": "83",
        "hot": 1,
        "types": [
            "动作",
            "科幻",
            "动画"
        ],
        "country": "日本",
        "year": "1995",
    },
    {
        "_id": "682da14ba9d2e7026f9c3016",
        "name": "幽灵公主",
        "score": "8.9",
        "duration": "134",
        "hot": 0,
        "types": [
            "动画",
            "奇幻",
            "冒险"
        ],
        "country": "日本",
        "year": "1997",
    },
    {
        "_id": "682da1d6a9d2e7026f9c301e",
        "name": "情书",
        "score": "8.9",
        "duration": "117",
        "hot": 1,
        "types": ["爱情"],
        "country": "日本",
        "year": "1995",
    },
    {
        "_id": "682ef55afa09000092007cbe",
        "name": "诡才之道",
        "duration": "112",
        "hot": 1,
        "types": [
            "喜剧",
            "恐怖"
        ],
        "country": '中国台湾',
        "year": "2024",
    },
    {
        "_id": "6830407c5b05254ad43ad998",
        "name": "终极对弈",
        "score": "7.3",
        "country": '韩国',
        "duration": "116",
        "hot": 0,
        "types": [
            "剧情", "传记"
        ],
        "year": "2025",
    },
    {
        "_id": "682f31885631163b8565d71f",
        "name": "大风杀",
        "score": "7.0",
        "country": '中国大陆',
        "duration": "131",
        "hot": 1,
        "types": [
            "悬疑",
            "犯罪",
            "剧情"
        ],
        "year": "2025",
    }
]);
const tableThead = ref([
    { name: '编号', value: '_id' },
    { name: '电影名称', value: 'name' },
    { name: '电影类型', value: 'types' },
    { name: '制片国家', value: 'country' },
    { name: '上映年份', value: 'year' },
    { name: '时长', value: 'duration' },
    { name: '热映', value: 'hot' },
    {name:'操作',value:'operate'}
]);

//删除
function deleteMovie(data) {
     moviesData.value = moviesData.value.filter(item => {
        return item._id != data
    })
}

const shopArray = ref([
    { id: 1, name: '苹果', price: 10, number: 10, isChose: false },
    { id: 2, name: '山竹', price: 24, number: 10, isChose: false },
    { id: 3, name: '榴莲', price: 45, number: 1, isChose: false },
    { id: 4, name: '西瓜', price: 2, number: 1, isChose: false }
]);
const shopHeader = ref([
    { name: '编号', value: 'id' },
    { name: '商品名称', value: 'name' },
    { name: '商品单价', value: 'price' },
    { name: '商品数量', value: 'number' },
]);

</script>

<style scoped></style>